<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="frm" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<script type="text/javascript">

    function saveBook() {
        $("#addBookFormId").submit();        
    }

    function cancelSave() {
       window.location.href = "home";
    }

</script>
<frm:form id="cancelAddBook" action="/home"/>
<frm:form id="addBookFormId" action="saveNewBook" modelAttribute="addBookFormBean"
          method="POST">
    <fmt:setBundle basename='labels' />
    <table>
        <tr>
            <td>
                <fmt:message key="caption.addBookForm.title"/>
            </td>
            <td>
                <frm:hidden id="bookTitle" path="id"/>
                <frm:input id="bookTitle" path="title" maxlength="20"/>
                <frm:errors path="title" cssClass="error"/>
            </td>
        </tr>
        <tr>
            <td>
                <fmt:message key="caption.addBookForm.authors"/>
            </td>
            <td>
                <frm:input id="bookAuthors" path="authors" maxlength="20"/>
            </td>
        </tr>
        <tr>
            <td>
                <fmt:message key="caption.addBookForm.pubDate"/>
            </td>
            <td>
                <frm:input id="bookPubDate" path="pubDate" maxlength="20"/>
            </td>
        </tr>
    </table>
    <input id="saveBtn" width="90px;" type="button" onclick="saveBook()" value="Save">
    <input id="cancelBtn" width="90px;" type="button" onclick="cancelSave()" value="Cancel">
</frm:form>
